<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
  <style>
    .box {width: 200px; height: 100px; background: #ccc; border: 1px solid #666;}
    .slide-enter {height: 0;}
    .slide-enter-active {transition: 1s all ease}
    .slide-enter-to {height: 100px;}
    .slide-leave {height: 100px;}
    .slide-leave-active {transition: 1s all ease}
    .slide-leave-to {height: 0;}
  </style>
  <script>
    window.onload = function() {
      new Vue({
        el: '#div1',
        data: {
          arr: [
            {id: 1, show: true},
            {id: 2, show: true},
            {id: 3, show: true},
            {id: 4, show: true},
          ]
        },
        methods: {
          fn (index) {
            this.arr[index].show = !this.arr[index].show
          }
        }
      })
    }
  </script>
</head>
<body>
  <div id="div1">
    <div>
      <input v-for="a,index in arr" :key="index" type="button" :value="'显示/隐藏' + index" @click="fn(index)">
      <transition-group name="slide">
        <div class="box" v-for="a,index in arr" :key="index" v-if="a.show">{{index}}</div>
      </transition-group>
    </div>
  </div>
</body>
</html>
